const inquirer = require('inquirer')
const initSetting = async template => {
  if (template === 'helper') {
    let isDefault = (await inquirer.prompt([{
      type: 'list',
      message: '是否采用默认配置:',
      name: 'isDefault',
      choices: ['true', 'false'],
      filter: function (val) {
        return val === 'true';
      }
    }])).isDefault
    if (isDefault) return defaults[template]

    const prompt = prompts[template]
    return inquirer.prompt(prompt)
  }
}

const defaults = {
  "helper": {
    author: 'linyi',
    testUtilType: 'mocha',
    coverageUtilType: 'coveralls',
    isTplSupport: true
  }
  ,
  "web": {
  }
  ,
  "react": {}
  ,
  "next": {}
  ,
  "express": {}
  ,
  "three": {}
  ,
}

const prompts = {
  "helper": [
    {
      type: 'list',
      message: '采用测试工具:',
      name: 'testUtilType',
      choices: ['mocha', 'jest'],
    },
    {
      type: 'list',
      message: '采用覆盖率展示工具:',
      name: 'coverageUtilType',
      choices: ['coveralls', 'codecov'],
    }
  ],
  "web": [

  ],
  "react": [

  ],
  "next": [

  ],
  "express": [

  ],
  "three": [

  ],
}



module.exports = initSetting